package com.jhyspringcloud.user.controller;


import com.jhyspringcloud.config.pojo.dto.UserDto;
import com.jhyspringcloud.user.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/user")
@RefreshScope
public class UserHomeController {

    @Resource
    UserService userService;

    //    @Value("${cat.name:name123123}")
//    @Value("${pattern.dateformat}")
    private String dateformat;

    @RequestMapping("/{id}")
    public UserDto findOrderById(@PathVariable("id") Long id) {
        return userService.findOrderById(id);

    }

    @RequestMapping("testConfig")
    public String testConfig() {
        return dateformat;
    }

    /**
     * @author: robert
     * @description: 测试gatewayFilter
     * 测试了下RequestHeader 这个注解没有区分大小写
     * @date: 2021/9/10 16:21
     * @return
     */
    @GetMapping("testGatewayFilter")
    public String testGatewayFilter(@RequestHeader(value = "truth",required = true) String treu, HttpServletRequest request, HttpServletResponse response){
        System.err.println("---->"+treu);
        return treu;
    }

}
